$(document)
		.ready(
				function() {

					$(".uname")
							.change(
									function() {
										var uname = $(this).val();
										if (uname.length > 3) {
											$(".status")
													.html(
															"<img src='images/loading.gif'><font color=gray> Checking availability...</font>");
											$
													.ajax({
														type : "POST",
														url : "check",
														data : "uname=" + uname,
														success : function(msg) {

															$(".status")
																	.ajaxComplete(
																			function(
																					event,
																					request,
																					settings) {

																				$(
																						".status")
																						.html(
																								msg);

																			});
														}
													});

										} else {

											$(".status")
													.html(
															"<font color=red>username shold be <b>3</b> chars</font>");
										}
									});

					$('form input[name="email"]')
							.blur(
									function() {
										var email = $(this).val();
										var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/igm;
										if (email == "") {
											$('.mail')
													.html(
															"<font color=blue>enter your email</font>");
										} else if (re.test(email)) {

											$('.mail')
													.html(
															"<font color=green>valid</font>");
										} else {

											$('.mail')
													.html(
															"<font color=red>enter a valid email</font>");
										}

									});
					$('form input[name="fname"]')
							.blur(
									function() {
										var fname = $(this).val();
										var re = /^[a-zA-Z]*$/;
										if (fname == "") {
											// $('.fn').hide();
											$('.fn')
													.html(
															"<font color=blue>enter your name</font>");
										}

										else if (re.test(fname)) {
											// $('.fn').hide();
											$('.fn')
													.html(
															"<font color=green>correct</font>");
										} else {
											// $('.fn').hide();
											$('.fn')
													.html(
															"<font color=red>Enter only characters</font>");
										}
									});

					$('form input[name="lname"]')
							.blur(
									function() {
										var lname = $(this).val();
										var re = /^[a-zA-Z]*$/;
										if (lname == "") {

											$('.ln')
													.html(
															"<font color=blue>enter your name</font>");
										}

										else if (re.test(lname)) {

											$('.ln')
													.html(
															"<font color=green>correct</font>");
										} else {

											$('.ln')
													.html(
															"<font color=red>Enter only characters</font>");
										}
									});
					$('form input[name="pass1"]')
							.change(
									function() {
										var pass1 = $(this).val();
										var re = /^[A-Za-z0-9 _]*[A-Za-z0-9][A-Za-z0-9 _]*$/;
										if (pass1.length >= 6) {
											if (re.test(pass1)) {
												$('.pass1')
														.html(
																"<font color=green>correct</font>");

											}
										} else {
											$('.pass1')
													.html(
															"<font color=red>enter minimum 6 characters</font>");
										}

										$('form input[name="pass2"]')
												.change(
														function() {
															var pass2 = $(this)
																	.val();
															// var re1
															// =/^[A-Za-z0-9
															// _]*[A-Za-z0-9][A-Za-z0-9
															// _]*$/;
															// if(pass2.length
															// == pass1.length){
															if (pass2 == pass1) {

																$('.pass2')
																		.html(
																				"<font color=green>correct</font>");

															} else {
																$('.pass2')
																		.html(
																				"<font color=red>password not match</font>");
															}

														});
									});
				});